import Vue from 'vue'
import VueRouter from 'vue-router'

// 引入登录组件
import reports from '@/views/report-index.vue'
import login from '@/views/login.vue'
import home from '@/views/home.vue'
import welcome from '@/views/welcome.vue'
import user from '@/views/user/user.vue'
import rightList from '@/views/rights/rightList.vue'
import roleList from '@/views/rights/roleList.vue'
import goodMan from '@/views/goods/goodMan.vue'
import goodList from '@/views/goods/goodList.vue'
import addGood from '@/views/goods/addGood.vue'
Vue.use(VueRouter)

// 创建路由对象
var router = new VueRouter({
  routes: [
    // 进行路由重定向
    {
      name: 'default',
      path: '/',
      redirect: { name: 'login' }
    },
    {
      name: 'login',
      path: '/login',
      component: login
    },
    {
      name: 'home',
      path: '/home',
      component: home,
      redirect: { name: 'welcome' },
      children: [
        {
          name: 'welcome',
          path: 'welcome',
          component: welcome
        },
        {
          name: 'reports',
          path: 'reports',
          component: reports
        },
        {
          name: 'user',
          path: 'users',
          component: user
        },
        {
          name: 'rightList',
          path: 'rights',
          component: rightList
        },
        {
          name: 'roleList',
          path: 'roles',
          component: roleList
        },
        {
          name: 'goodMan',
          path: 'goods',
          component: goodMan,
          redirect: { name: 'goodList' },
          children: [
            {
              name: 'goodList',
              path: 'list',
              component: goodList
            },
            {
              name: 'addGood',
              path: 'add',
              component: addGood
            }
          ]
        }
      ]
    }

  ]
})

// 暴露
export default router
